<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <title>Title</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
  <style>
    html,body{
        width:1000px;
        margin: 0 auto;
    }
  </style>
</head>
<body>
<div>
  <h1 class="animate__animated animate__heartBeat">An animated element</h1>
</div>
<div></div>
<script>
    var data = [
    {
      id: "8D3E8E0CF883C4E99329AF8A29300AB6",
      name: "学习",
      children: [
        {
          id: "A87E76E7B9A393ECCA39C3EDB6A89A03",
          name: "JAVA",
          children: [
            {
              id: "74C74ADC58BCA5D859547DFFCDF3D99C",
              name: "基础",
              children: null
            },
            {
              id: "A2BE9686625CC07FD32227389AE4BA6C",
              name: "进阶",
              children: null
            }
          ]
        },
        {
          id: "94B9F5654A84A0AAFD988768DE6EF592",
          name: "Python",
          children: [
            {
              id: "3893FECF50DC12B69568E241E7DBCDEE",
              name: "基础",
              children: null
            },
            {
              id: "E30DAE51273B2AD406B014FBFB298841",
              name: "进阶",
              children: null
            }
          ]
        },
        {
          id: "5BEA081B47267242F2E83CC5844B3FD1",
          name: "HTML",
          children: [
            {
              id: "C6FC907C6B84715F2E4861689497B748",
              name: "基础",
              children: null
            },
            {
              id: "8B2239557532573E4DE9945F2CBDED7B",
              name: "进阶",
              children: null
            }
          ]
        }
      ]
    },
    {
      id: "B90CFD2221AD6AC54BCA39379B1C4F1E",
      name: "日记",
      children: [
        {
          id: "621515573240F3B4029936A25C14DDF3",
          name: "备忘",
          children: []
        },
        {
          id: "75A4D5C73B8FA10E7D651B1813E21EA3",
          name: "生活",
          children: []
        }
      ]
    },
    {
      id: "DC3EE4A60028E21B4F025D864146516A",
      name: "博客",
      children: []
    },
    {
      id: "88A18AF76E975CF865E69540102D2616",
      name: "游戏",
      children: [
        {
          id: "46DDAC99DD1BD358E7917769B3775500",
          name: "活动",
          children: []
        }
      ]
    }
    ]
    function recursionFindObj(data, id){
      var result = null;
      if(!data){
        // return; 中断执行
        return;
      }
      for(let i in data){
        // 已经找到了属性值所在的对象就终止循环,以免后面的循环覆盖result,导致出错
        if(result !== null){
          break;
        }
        var item = data[i];
        if(item.id == id){
          result = item;
          break;
        }else if(item.children){
          result = recursionFindObj(item.children, id);
        }
      }
      return result;
    }
    var result = recursionFindObj(data,'A87E76E7B9A393ECCA39C3EDB6A89A03')
    console.log(result)
</script>
</body>
</html>